package com.audaque.springboot.foshanupload.web.rocketmqdemo.listener;

import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;


@Service
//rocketmq 报 The consumer group has been created before, specify another name please. 错误
//是因为一个springboot服务配置了多个consumer，但没有指定instanceName。确保instanceName唯一就可以，consumer的实例名，在同一个group中保证唯一，可以用Topic名。
@RocketMQMessageListener(consumerGroup = "broadcasting-string-push", topic = "broadcasting-string", messageModel = MessageModel.BROADCASTING,instanceName="copy")
public class BroadCastingConsumerListenerCopy implements RocketMQListener<String> {
    @Override
    public void onMessage(String s) {
        System.out.println("广播模式 消费者Copy，消费消息：" + s);
    }
}